<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 10] Float</TITLE>
<META NAME="author" CONTENT="Mark Grand">
<META NAME="date" CONTENT="Fri Aug  8 15:24:32 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="java">
<META NAME="title" CONTENT="Java Language Reference">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java Language Reference" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch10_08.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 10<br>The java.lang Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch10_10.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=refnamediv>
<H1>Float</H1>

<H2>Name</H2>

Float

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.63">Synopsis</A></h2>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Class Name:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.lang.Float</tt>

<p>
<DT CLASS=varlistentry>Superclass:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.lang.Number</tt>

<p>
<DT CLASS=varlistentry>Immediate Subclasses:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Interfaces Implemented:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Availability:<br>
<DD>

<P CLASS=para>
JDK 1.0 or later</DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.64">Description</A></h2>

<P CLASS=para>
<A NAME="MAN.FLOAT.1"></A>The <tt CLASS=literal>Float</tt> class provides an object wrapper
for a <tt CLASS=literal>float</tt> value. This is useful when you need
to treat a <tt CLASS=literal>float</tt> value as an object. For example,
there are a number of utility methods that take a reference to an
<tt CLASS=literal>Object</tt> as one of their arguments. You cannot
specify a <tt CLASS=literal>float</tt> value for one of these arguments,
but you can provide a reference to a <tt CLASS=literal>Float</tt> object
that encapsulates the <tt CLASS=literal>float</tt> value. Furthermore,
as of JDK 1.1, the <tt CLASS=literal>Float</tt> class is necessary to 
support the Reflection API and class literals.

<P CLASS=para>
In Java, <tt CLASS=literal>float</tt> values are represented using
the IEEE 754 format. The <tt CLASS=literal>Float</tt> class provides
constants for the three special values that are mandated by this format:
<tt CLASS=literal>POSITIVE_INFINITY</tt>, <tt CLASS=literal>NEGATIVE_INFINITY</tt>,
and <tt CLASS=literal>NaN</tt> (not-a-number).

<P CLASS=para>
The <tt CLASS=literal>Float</tt> class also provides some utility
methods, such as methods for determining whether a <tt CLASS=literal>floatx</tt>
value is an infinity value or NaN, for converting <tt CLASS=literal>float</tt>
values to other primitive types, and for converting a <tt CLASS=literal>float</tt>
to a <tt CLASS=literal>String</tt> and vice versa.

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.65">Class Summary</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public final class java.lang.Float extends java.lang.Number {
    // Constants
    public static final float MIN_VALUE;
    public static final float MAX_VALUE;
    public static final float NaN;
    public static final float NEGATIVE_INFINITY;
    public static final float POSITIVE_INFINITY;
    public final static Class TYPE;                    // New in 1.1
    // Constructors
    public Float(double value);
    public Float(float value);
    public Float(String s);
    // Class Methods
    public static native int floatToIntBits(float value);
    public static native float intBitsToFloat(int bits);
    public static boolean isInfinite(float v);
    public static boolean isNaN(float v);
    public static String toString(float f);
    public static Float valueOf(String s);
    // Instance Methods
    public byte byteValue();                           // New in 1.1
    public double doubleValue();
    public boolean equals(Object obj);
    public float floatValue();
    public int hashCode();
    public int intValue();
    public boolean isInfinite();
    public boolean isNaN();
    public long longValue();
    public short shortValue();                         // New in 1.1
    public String toString();
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.66">Constants</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.164">MAX_VALUE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.170"><tt CLASS=literal>public static final float MAX_VALUE = 3.40282346638528860e+38f</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The largest value that can be represented by a <tt CLASS=literal>float</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.165">MIN_VALUE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.171"><tt CLASS=literal>public static final float MIN_VALUE = 1.40129846432481707e-45f</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The smallest value that can be represented by a <tt CLASS=literal>float</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.166">NaN</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.172"><tt CLASS=literal>public static final float NaN = 0.0f / 0.0f</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This variable represents the value NaN, a special value produced by <tt CLASS=literal>float</tt> operations
such as division of zero by zero. When NaN is one of the operands,
most arithmetic operations return NaN as the result.
Most comparison operators (<tt CLASS=literal>&lt;</tt>, <tt CLASS=literal>&lt;=</tt>,
<tt CLASS=literal>==</tt>, <tt CLASS=literal>&gt;=</tt>, <tt CLASS=literal>&gt;</tt>)
return <tt CLASS=literal>false</tt> when one of their arguments is NaN.
The exception is <tt CLASS=literal>!=</tt>, which returns <tt CLASS=literal>true</tt>
when one of its arguments is NaN.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.167">NEGATIVE_INFINITY</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.173"><tt CLASS=literal>public static final float NEGATIVE_INFINITY = -1.0f / 0.0f</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This variable represents the value negative infinity, which
is produced when a <tt CLASS=literal>float</tt> operation underflows
or a negative <tt CLASS=literal>float</tt> value is divided by zero.
Negative infinity is by definition less than any other <tt CLASS=literal>float</tt>
value.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.168">POSITIVE_INFINITY</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.174"><tt CLASS=literal>public static final float POSITIVE_INFINITY = 1.0f / 0.0f</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This variable represents the value positive infinity, which
is produced when a <tt CLASS=literal>float</tt> operation overflows
or a positive <tt CLASS=literal>float</tt> value is divided by zero.
Positive infinity is by definition greater than any other <tt CLASS=literal>float</tt>
value.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.169">TYPE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.175"><tt CLASS=literal>public static final Class TYPE </tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Availability<br>
<DD>

<P CLASS=para>
New as of JDK 1.1

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Class</tt> object that represents the type
<tt CLASS=literal>float</tt>.
It is always true that <tt CLASS=literal>Float.TYPE</tt> 
<tt CLASS=literal>==</tt> <tt CLASS=literal>float.class</tt>.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.67">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.170">Float</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.176"><tt CLASS=literal>public Float(double value)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>double</tt> value to be encapsulated
by this object.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Creates a <tt CLASS=literal>Float</tt> object with the specified
<tt CLASS=literal>double</tt> value. The value is rounded to <tt CLASS=literal>float</tt>
precision.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.177">public Float(float value)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>float</tt> value to be encapsulated
by this object.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Creates a <tt CLASS=literal>Float</tt> object with the specified
<tt CLASS=literal>float</tt> value.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.178">public Float(String s) throws NumberFormatException</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The string to be made into a <tt CLASS=literal>Float</tt>
object.</DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the sequence of characters in the given <tt CLASS=literal>String</tt>
does not form a valid <tt CLASS=literal>float</tt> literal.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>Float</tt> object with the value
specified by the given string. The string must contain a sequence
of characters that forms a legal <tt CLASS=literal>float</tt> literal.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.68">Class Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.171">floatToIntBits</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.179"><tt CLASS=literal>public static native int floatToIntBits(float value)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>float</tt> value to be converted.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>int</tt> value that contains the same sequence
of bits as the representation of the given <tt CLASS=literal>float</tt> value.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the <tt CLASS=literal>int</tt> value that
contains the same sequence of bits as the representation of the
given <tt CLASS=literal>float</tt> value. The meaning of the bits in
the result is defined by the IEEE 754 floating-point format: bit
31 is the sign bit, bits 30-23 are the exponent, and bits 22-0 are
the mantissa. An argument of <tt CLASS=literal>POSITIVE_INFINITY</tt>
produces the result <tt CLASS=literal>0x7f800000</tt>, an argument of
<tt CLASS=literal>NEGATIVE_INFINITY</tt> produces the result <tt CLASS=literal>0xff800000</tt>,
and an argument of <tt CLASS=literal>NaN</tt> produces the result <tt CLASS=literal>0x7fc00000</tt>.

<P CLASS=para>
The value returned by this method can be converted back to
the original <tt CLASS=literal>float</tt> value by the
<tt CLASS=literal>intBitsToFloat()</tt> method.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.172">intBitsToFloat</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.180"><tt CLASS=literal>public static native float intBitsToFloat(int bits)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>bits</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>int</tt> value to be converted.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>float</tt> value whose representation is
the same as the bits in the given <tt CLASS=literal>int</tt> value.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the <tt CLASS=literal>float</tt> value whose
representation is the same as the bits in the given <tt CLASS=literal>int</tt>
value. The meaning of the bits in the <tt CLASS=literal>int</tt>
value is defined by the IEEE 754 floating-point format: bit 31 is
the sign bit, bits 30-23 are the exponent, and bits 22-0 are the
mantissa. The argument <tt CLASS=literal>0x7f800000</tt> produces the
result <tt CLASS=literal>POSITIVE_INFINITY</tt>, and the argument <tt CLASS=literal>0xff800000</tt>
produces the result <tt CLASS=literal>NEGATIVE_INFINITY</tt>. Arguments
in the ranges <tt CLASS=literal>0x7f800001</tt> through <tt CLASS=literal>0x7f8fffff</tt>
and <tt CLASS=literal>0xff800001</tt> through <tt CLASS=literal>0xff8fffffL</tt>
all produce the result <tt CLASS=literal>NaN</tt>.

<P CLASS=para>
Except for NaN values not normally used by Java, this method
is the inverse of the <tt CLASS=literal>floatToIntBits()</tt> method.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.173">isInfinite</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.181"><tt CLASS=literal>public static boolean isInfinite(float v)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>v</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>float</tt> value to be tested.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the specified value is equal to
<tt CLASS=literal>POSITIVE_INFINITY</tt> or <tt CLASS=literal>NEGATIVE_INFINITY</tt>;
otherwise <tt CLASS=literal>false</tt>.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method determines whether or not the specified value
is an infinity value.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.174">isNaN</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.182"><tt CLASS=literal>public static boolean isNaN(float v)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>v</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>float</tt> value to be tested.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the specified value is equal to
<tt CLASS=literal>NaN</tt>; otherwise <tt CLASS=literal>false</tt>.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method determines whether or not the specified value
is NaN.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.175">toString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.183"><tt CLASS=literal>public static String toString(float f)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>f</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>float</tt> value to be converted.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A string representation of the given value.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains a representation of the given <tt CLASS=literal>float</tt> value.

<P CLASS=para>
The values <tt CLASS=literal>NaN</tt>, <tt CLASS=literal>NEGATIVE_INFINITY</tt>, <tt CLASS=literal>POSITIVE_INFINITY</tt>,
<tt CLASS=literal>-0.0</tt>, and <tt CLASS=literal>+0.0</tt> are represented by
the strings <tt CLASS=literal>"NaN"</tt>,
<tt CLASS=literal>"--Infinity"</tt>, <tt CLASS=literal>"Infinity"</tt>,
<tt CLASS=literal>"--0.0"</tt>, and <tt CLASS=literal>"0.0"</tt>,
respectively.

<P CLASS=para>
For other values, the exact string representation depends
on the value being converted. If the absolute value of <tt CLASS=literal>f</tt>
is greater than or equal to 10^-3 
or less than or equal to 10^7, it
is converted to a string with an optional minus sign (if the
value is negative) followed by up to eight digits
before the decimal point, a decimal point, and the necessary number
of digits after the decimal point (but no trailing zero if there is 
more than one significant digit).  There is always a minimum of
one digit after the decimal point.

<P CLASS=para>
Otherwise, the value is converted to a string with an optional
minus sign (if the value is negative), followed by a single digit,
a decimal point, the necessary number of digits after the decimal
point (but no trailing zero if there is more than one significant digit),
and the letter <tt CLASS=literal>E</tt> followed by a plus or a minus 
sign and a base 10 exponent of at least one digit.  Again, there is always 
a minimum of one digit after the decimal point.

<P CLASS=para>
Note that the definition of this method has changed as of JDK 1.1.  
Prior to that release, the method provided a string representation
that was equivalent to the <tt CLASS=literal>%g</tt> format of 
the <tt CLASS=literal>printf</tt> function in C.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.176">valueOf</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.184"><DIV CLASS=screen> <P> <PRE> public static Float valueOf(String s) throws NumberFormatException </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The string to be made into a <tt CLASS=literal>Float</tt>
object.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Float</tt> object constructed from the string.

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the sequence of characters in the given <tt CLASS=literal>String</tt>
does not form a valid <tt CLASS=literal>float</tt> literal.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>Float</tt> object with the value
specified by the given string. The string must contain a sequence
of characters that forms a legal <tt CLASS=literal>float</tt> literal.
This method ignores leading and trailing whitespace in the string.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.69">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.177">byteValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.185"><tt CLASS=literal>public byte byteValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Availability<br>
<DD>

<P CLASS=para>
New as of JDK 1.1

<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>byte</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.byteValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the truncated value of this object as a
<tt CLASS=literal>byte</tt>. More specifically, if the value of the object
is <tt CLASS=literal>NaN</tt>, the method returns 0. If the value is
<tt CLASS=literal>POSITIVE_INFINITY</tt>, or any other value that is too
large to be represented by an <tt CLASS=literal>byte</tt>, the method
returns <tt CLASS=literal>Byte.MAX_VALUE</tt>. If the value is
<tt CLASS=literal>NEGATIVE_INFINITY</tt>, or any other value that is too
small to be represented by an <tt CLASS=literal>byte</tt>, the method
returns <tt CLASS=literal>Byte.MIN_VALUE</tt>. Otherwise, the value is
rounded toward zero and returned.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.178">doubleValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.186"><tt CLASS=literal>public double doubleValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>double</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.doubleValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>double</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.179">equals</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.187"><tt CLASS=literal>public boolean equals(Object obj)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>obj</tt><br>
<DD>

<P CLASS=para>
The object to be compared with this object.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the objects are equal; <tt CLASS=literal>false</tt>
if they are not.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.equals()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns <tt CLASS=literal>true</tt> if <tt CLASS=literal>obj</tt>
is an instance of <tt CLASS=literal>Float</tt> and it contains the same
value as the object this method is associated with. More specifically,
the method returns <tt CLASS=literal>true</tt>
if the <tt CLASS=literal>floatToIntBits()</tt>
method returns the same result for the values of both
objects.

<P CLASS=para>
This method produces a different result than the <tt CLASS=literal>==</tt>
operator when both values are <tt CLASS=literal>NaN</tt>. In this case,
the <tt CLASS=literal>==</tt> operator produces <tt CLASS=literal>false</tt>,
while this method returns <tt CLASS=literal>true</tt>. By the same token,
the method also produces a different result when the two values
are <tt CLASS=literal>+0.0</tt> and <tt CLASS=literal>-0.0</tt>. In this
case, the <tt CLASS=literal>==</tt> operator produces <tt CLASS=literal>true</tt>,
while this method returns <tt CLASS=literal>false</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.180">floatValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.188"><tt CLASS=literal>public float floatValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>float</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.floatValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>float</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.181">hashCode</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.189"><tt CLASS=literal>public int hashCode()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A hashcode based on the <tt CLASS=literal>float</tt> value of
the object.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.hashCode()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a hashcode computed from the value of
this object. More specifically, if <tt CLASS=literal>f</tt> is the value
of the object, this method returns <tt CLASS=literal>Float.floatToIntBits(f)</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.182">intValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.190"><tt CLASS=literal>public int intValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as an <tt CLASS=literal>int</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.intValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the truncated value of this object as an
<tt CLASS=literal>int</tt>. More specifically, if the value of the object
is <tt CLASS=literal>NaN</tt>, the method returns 0. If the value is
<tt CLASS=literal>POSITIVE_INFINITY</tt>, or any other value that is too
large to be represented by an <tt CLASS=literal>int</tt>, the method
returns <tt CLASS=literal>Integer.MAX_VALUE</tt>. If the value is
<tt CLASS=literal>NEGATIVE_INFINITY</tt>, or any other value that is too
small to be represented by an <tt CLASS=literal>int</tt>, the method
returns <tt CLASS=literal>Integer.MIN_VALUE</tt>. Otherwise, the value is
rounded toward zero and returned.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.183">isInfinite</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.191"><tt CLASS=literal>public boolean isInfinite(float v)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the value of this object is equal
to <tt CLASS=literal>POSITIVE_INFINITY</tt> or <tt CLASS=literal>NEGATIVE_INFINITY</tt>;
otherwise <tt CLASS=literal>false</tt>.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method determines whether or not the value of this object
is an infinity value.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.184">isNaN</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.192"><tt CLASS=literal>public boolean isNaN()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the value of this object is equal
to <tt CLASS=literal>NaN</tt>; otherwise <tt CLASS=literal>false</tt>.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method determines whether or not the value of this object
is NaN.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.185">longValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.193"><tt CLASS=literal>public long longValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>long</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.longValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the truncated value of this object as a
<tt CLASS=literal>long</tt>. More specifically, if the value of the object
is <tt CLASS=literal>NaN</tt>, the method returns 0. If the value is
<tt CLASS=literal>POSITIVE_INFINITY</tt>, or any other value that is too
large to be represented by a <tt CLASS=literal>long</tt>, the method
returns <tt CLASS=literal>Long.MAX_VALUE</tt>. If the value is
<tt CLASS=literal>NEGATIVE_INFINITY</tt>, or any other value that is too
small to be represented by a <tt CLASS=literal>long</tt>, the method
returns <tt CLASS=literal>Long.MIN_VALUE</tt>. Otherwise, the value is
rounded toward zero and returned.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.186">shortValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.194"><tt CLASS=literal>public short shortValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Availability<br>
<DD>

<P CLASS=para>
New as of JDK 1.1

<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>short</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.shortValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the truncated value of this object as a
<tt CLASS=literal>short</tt>. More specifically, if the value of the object
is <tt CLASS=literal>NaN</tt>, the method returns 0. If the value is
<tt CLASS=literal>POSITIVE_INFINITY</tt>, or any other value that is too
large to be represented by an <tt CLASS=literal>short</tt>, the method
returns <tt CLASS=literal>Short.MAX_VALUE</tt>. If the value is
<tt CLASS=literal>NEGATIVE_INFINITY</tt>, or any other value that is too
small to be represented by an <tt CLASS=literal>short</tt>, the method
returns <tt CLASS=literal>Short.MIN_VALUE</tt>. Otherwise, the value is
rounded toward zero and returned.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.187">toString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.195"><tt CLASS=literal>public String toString()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A string representation of the value of this object.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.toString()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains a representation of the value of this object.

<P CLASS=para>
The values <tt CLASS=literal>NaN</tt>,<tt CLASS=literal> NEGATIVE_INFINITY</tt>,
<tt CLASS=literal>POSITIVE_INFINITY</tt>, <tt CLASS=literal>-0.0</tt>, and
<tt CLASS=literal>+0.0</tt> are represented by 
the strings <tt CLASS=literal>"NaN"</tt>, <tt CLASS=literal>"--Infinity"</tt>, 
<tt CLASS=literal>"Infinity"</tt>, <tt CLASS=literal>"--0.0"</tt>, 
and <tt CLASS=literal>"0.0"</tt>, respectively.

<P CLASS=para>
For other values, the exact string representation depends
on the value being converted. If the absolute value of this object
is greater than or equal to 10^-3 
or less than or equal to 10^7, it
is converted to a string with an optional minus sign (if the
value is negative) followed by up to eight digits
before the decimal point, a decimal point, and the necessary number
of digits after the decimal point (but no trailing zero if there is 
more than one significant digit).  There is always a minimum of
one digit after the decimal point.

<P CLASS=para>
Otherwise, the value is converted to a string with an optional
minus sign (if the value is negative), followed by a single digit,
a decimal point, the necessary number of digits after the decimal
point (but no trailing zero if there is more than one significant digit),
and the letter <tt CLASS=literal>E</tt> followed by a plus or a minus 
sign and a base 10 exponent of at least one digit. Again, there is always 
a minimum of one digit after the decimal point.

<P CLASS=para>
Note that the definition of this method has changed as of JDK 1.1.  
Prior to that release, the method provided a string representation
that was equivalent to the <tt CLASS=literal>%g</tt> format of 
the <tt CLASS=literal>printf</tt> function in C.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.70">Inherited Methods</A></h2>

<DIV CLASS=informaltable>
<P>
<TABLE CLASS=INFORMALTABLE>
<TR CLASS=row>
<TH ALIGN="left">

<P CLASS=para>
Method</TH>
<TH ALIGN="left">

<P CLASS=para>
Inherited From</TH>
<TH ALIGN="left">

<P CLASS=para>
Method</TH>
<TH ALIGN="left">

<P CLASS=para>
Inherited From</TH>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>clone()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>finalize()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>getClass()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>notify()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>notifyAll()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait(long)</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait(long, int)</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
</TABLE>
<P>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.71">See Also</A></h2>

<P CLASS=para>
<A HREF="ch10_04.htm">Class</A>;
<A HREF="ch10_08.htm">Double</A>;
<A HREF="ch09_04.htm#JLR2-CH-9-SECT-4.1">Exceptions</A>;
<A HREF="ch02_02.htm#JLR2-CH-2-SECT-2.3.2">Floating-point literals</A>;
<A HREF="ch03_01.htm#JLR2-CH-3-SECT-1.1.2">Floating-point types</A>;
<A HREF="ch10_13.htm">Number</A>;
<A HREF="ch10_20.htm">String</A>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch10_08.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch10_10.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>Double</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>Integer</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
